



#ifndef _PDF_FONT_EXTENDED_H_
#define _PDF_FONT_EXTENDED_H_

#include <wx/mstream.h>
#include <wx/string.h>

#include "wx/pdfdocdef.h"
#include "wx/pdfarraytypes.h"
#include "wx/pdffontdata.h"

class WXDLLIMPEXP_FWD_PDFDOC wxPdfEncoding;
class WXDLLIMPEXP_FWD_PDFDOC wxPdfFont;
class WXDLLIMPEXP_FWD_PDFDOC wxPdfFontDescription;

/// Class representing a font providing an extended interface
class WXDLLIMPEXP_PDFDOC wxPdfFontExtended
{
public:
  /// Default constructor
  wxPdfFontExtended();

  /// Constructor
  
  wxPdfFontExtended(const wxPdfFont& font);

  /// Default destructor
  virtual ~wxPdfFontExtended() ;

  /// Copy constructor
  wxPdfFontExtended(const wxPdfFontExtended& font);

  /// Assignment
  wxPdfFontExtended& operator=(const wxPdfFontExtended& font);

  /// Check whether font is valid
  
  bool IsValid() const;

  /// Get font type
  
  wxString GetType() const;

  /// Get font family
  
  wxString GetFamily() const;

  /// Get font name
  
  wxString GetName() const;

  /// Get font style
  
  int GetStyle() const;

  /// Check whether font embedding is requested for this font
  
  bool EmbedRequested() const { return m_embed; }

  /// Check whether font subsetting is requested for this font
  
  bool SubsetRequested() const { return m_subset; }

  /// Get underline position
  
  int  GetUnderlinePosition() const;

  /// Get underline thickness
  
  int  GetUnderlineThickness() const;

  /// Get bounding box top position
  
  int GetBBoxTopPosition() const;

  /// Get encoding
  
  wxString GetEncoding() const;

  /// Get encoding
  
  wxString GetBaseEncoding() const;

  /// Check whether the font has differences to WinAnsi encoding
  
  bool HasDiffs() const;

  /// Get encoding differences
  
  wxString GetDiffs() const;

  /// Get font file size 1
  
  size_t  GetSize1() const;

  /// Check whether the file has a size 2
  
  bool HasSize2() const;

  /// Get font file size 2 (Type 1 only)
  
  size_t  GetSize2() const;

  /// Get the font's CMap (Type 0 only)
  
  wxString GetCMap() const;

  /// Get font ordering
  
  wxString GetOrdering() const;

  /// Get font supplement /Type 0 only)
  
  wxString GetSupplement() const;

  /// Get the character width array as string
  
  wxString GetWidthsAsString(bool subset = false, wxPdfSortedArrayInt* usedGlyphs = NULL, wxPdfChar2GlyphMap* subsetGlyphs = NULL) const;
  
  /// Get the width of a string
  
  double GetStringWidth(const wxString& s, bool withKerning = false);

  /// Get kerning width array
  
  wxArrayInt GetKerningWidthArray(const wxString& s) const;

  /// Check whether the font oan show all characters of a given string
  
  bool CanShow(const wxString& s) const;

  /// Convert character codes to glyph numbers
  
  wxString ConvertCID2GID(const wxString& s, wxPdfSortedArrayInt* usedGlyphs = NULL, wxPdfChar2GlyphMap* subsetGlyphs = NULL);

  /// Convert glyph number to string
  
  wxString ConvertGlyph(wxUint32 glyph, wxPdfSortedArrayInt* usedGlyphs = NULL, wxPdfChar2GlyphMap* subsetGlyphs = NULL);

  /// Check whether the font will be embedded
  
  bool IsEmbedded() const;

  /// Check whether the font supports subsetting
  
  bool SupportsSubset() const;

  /// Write font data 
  
  size_t WriteFontData(wxOutputStream* fontData, wxPdfSortedArrayInt* usedGlyphs, wxPdfChar2GlyphMap* subsetGlyphs);

  /// Write character/glyph to unicode mapping
  
  size_t WriteUnicodeMap(wxOutputStream* mapData, wxPdfSortedArrayInt* usedGlyphs, wxPdfChar2GlyphMap* subsetGlyphs);

  /// Get the font description
  const wxPdfFontDescription& GetDescription() const;

  /// Get user font
  
  wxPdfFont GetUserFont() const;

  /// Check whether the font has an encoding map
  
  bool HasEncodingMap() const;

#if wxUSE_UNICODE
  /// Get the associated encoding converter
  
  virtual wxMBConv* GetEncodingConv() const;
#endif

  bool HasVoltData() const;

  wxString ApplyVoltData(const wxString& txt) const;

protected:

private:
  // Constructor
  wxPdfFontExtended(const wxPdfFontData* fontData);

  bool                 m_embed;        ///< Flag whether the font should be embedded
  bool                 m_subset;       ///< Flag whether the font should be subsetted
  wxPdfFontData*       m_fontData;     ///< Real font data
  const wxPdfEncoding* m_encoding;     
  friend class wxPdfFontManagerBase;
};

#endif
